/*****************************************************************************

FileName: 	<cconvinit.cpp>

File Description:
Contains Modules to initialize the LUTs required for cconv modules

*****************************************************************************/


#include "cconvafx.h"


/*****************************************************************************
Routine:  void cconvInitTab()

returns        	: void
Description    	: Initializes the LUTs for yuvtorgb conversion
*****************************************************************************/
void cconvInitTab()
{
	long int crv,cbu,cgu,cgv;
	int i,ind;   

	crv = SCALECrv; cbu = SCALECbu;
	cgu = SCALECgu; cgv = SCALECgv;

	for (i = 0; i < 256; i++) {
		cconv_crv_tab[i] = (i-SHIFTCrv) * crv;
		cconv_cbu_tab[i] = (i-SHIFTCbu) * cbu;
		cconv_cgu_tab[i] = (i-SHIFTCgu) * cgu;
		cconv_cgv_tab[i] = (i-SHIFTCgv) * cgv;
		cconv_tab_76309[i] = SCALEY*(i-SHIFTY);

		cconv_yr_tab[i] = i*SCALEYR;
		cconv_yg_tab[i] = i*SCALEYG;
		cconv_yb_tab[i] = i*SCALEYB;

		cconv_ur_tab[i] = i*SCALEUR;
		cconv_ug_tab[i] = i*SCALEUG;
		cconv_ub_tab[i] = i*SCALEUB;

		cconv_vr_tab[i] = i*SCALEVR;
		cconv_vg_tab[i] = i*SCALEVG;
		cconv_vb_tab[i] = i*SCALEVB;

	}

	ind=0;	
	for (i=0; i<384; i++)
		cconv_clp[ind++] =0;
	ind=384;
	for (i=0;i<256; i++)
		cconv_clp[ind++]=i;
	ind=640;
	for (i=0;i<384;i++)
		cconv_clp[ind++]=255;

}



/*****************************************************************************
Routine:  void cconvInit()

returns        	: void
Description     : Wrapper Function for Calling Init functions
*****************************************************************************/
void cconvInit()
{

	cconvInitTab();	

}

